package org.jash.launcher.ui

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import androidx.databinding.DataBindingUtil
import com.alibaba.android.arouter.facade.annotation.Route
import org.jash.launcher.R
import org.jash.launcher.databinding.ActivityFrameBinding

@Route(path = "/launcher/frame")
class FrameActivity : AppCompatActivity() {
    val binding:ActivityFrameBinding by lazy { DataBindingUtil.setContentView(this, R.layout.activity_frame) }
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        supportFragmentManager.beginTransaction()
            .replace(R.id.frame, GatewayFragment.newInstance())
            .commit()
        binding.navigation.selectedItemId = R.id.gateway_menu
        binding.navigation.setOnItemSelectedListener {
            supportFragmentManager.beginTransaction()
                .replace(R.id.frame, when(it.itemId) {
                    R.id.message_menu -> MessageFragment.newInstance()
                    R.id.gateway_menu -> GatewayFragment.newInstance()
                    R.id.mine_menu -> MineFragment.newInstance()
                    else -> GatewayFragment.newInstance()
                })
                .commit()

            return@setOnItemSelectedListener true
        }
    }
}